/*
 *
 *
 */

#ifndef GKT_SLIDING_CLOSURE_H
#define GKT_SLIDING_CLOSURE_H

#include "gkt_types.h"

#ifdef __cplusplus
extern "C" {
#endif

#if defined(GKT_CONFIG_SLIDING_CLOSURE_ENABLE)	\
	&& GKT_CONFIG_SLIDING_CLOSURE_ENABLE

#define GKT_SLIDING_CLOSURE_ENABLE	1

typedef void (*gkt_sliding_closure_notify_fn)(int detect);

int gkt_sliding_closure_init(void);

int gkt_sliding_closure_is_detected(void);

void gkt_sliding_closure_register_notify(
			gkt_sliding_closure_notify_fn notify);

#if defined(GKT_CONFIG_SLIDING_CLOSURE_MAGNET_GPIO_PIN) \
	&& defined(GKT_CONFIG_SLIDING_CLOSURE_MAGNET_LEVEL)
#define GKT_SLIDING_CLOSURE_MAGNET_ENABLE	1
void gkt_sliding_closure_magnet_control(int magnetic);
void gkt_sliding_closure_magnet_degauss_sync(void);
#else
#define GKT_SLIDING_CLOSURE_MAGNET_ENABLE	0
#define gkt_sliding_closure_magnet_control(magnetic)	\
	do { gkt_unused(magnetic); } while(0)
#define gkt_sliding_closure_magnet_degauss_sync()	\
	do {} while(0)
#endif

#else

#define GKT_SLIDING_CLOSURE_ENABLE	0

#define gkt_sliding_closure_init()	GKT_SUCCESS
#define gkt_sliding_closure_is_detected()	0
#define gkt_sliding_closure_register_notify(notify)	\
	do { gkt_unused(notify); } while(0)

#define GKT_SLIDING_CLOSURE_MAGNET_ENABLE	0
#define gkt_sliding_closure_magnet_control(magnetic)	\
	do { gkt_unused(magnetic); } while(0)
#define gkt_sliding_closure_magnet_degauss_sync()	\
	do {} while(0)
#endif

#ifdef __cplusplus
}
#endif

#endif	/* GKT_SLIDING_CLOSURE_H */

